#include <nan.h>

namespace{
    void GetBattery(const Nan::FunctionCallbackInfo<v8::Value>& info) {
        // Your implementation for getDetails function
        // ...

        // For demonstration purposes, we print a message to the console
        printf("getDetails function called.\n");
    }
    void Initialize(v8::Local<v8::Object> exports) {
        Nan::HandleScope scope;

//         // 创建一个字典对象
//         v8::Local<v8::Object> chromeDictionary = Nan::New<v8::Object>();
//
//         v8::Local<v8::Object> chromeAppDictionary = Nan::New<v8::Object>();
// //         v8::Local<v8::Object> loadTimesObj = Nan::New<v8::Object>();
//         InitializeAppObject(chromeAppDictionary);
//         // 向字典对象添加对象属性
//         Nan::Set(chromeDictionary, Nan::New("loadTimes").ToLocalChecked(), Nan::GetFunction(Nan::New<v8::FunctionTemplate>(LoadTimes)).ToLocalChecked());
//         Nan::Set(chromeDictionary, Nan::New("app").ToLocalChecked(), chromeAppDictionary);

        // 向 exports 对象添加字典属性
        Nan::Set(exports, Nan::New("getBattery").ToLocalChecked(), Nan::GetFunction(Nan::New<v8::FunctionTemplate>(GetBattery)).ToLocalChecked());
    }
}

// 初始化 Node.js 模块
void InitializeModule(v8::Local<v8::Object> exports) {
    Nan::HandleScope scope;
    Initialize(exports);
}

// 使用 NAN_MODULE_INIT 替代 NODE_MODULE
NAN_MODULE_INIT(NODE_GYP_MODULE_NAME) {
    InitializeModule(target);
}

// NODE_MODULE(NODE_GYP_MODULE_NAME, NODE_GYP_MODULE_NAME)